export default {
    state: {
        name: "zhanghan"
    },
    mutations:{
        updateName(state, payload){
            state.name = payload;
        }
    },
    actions: {
        aUpdateName(context){
            console.log(context)
            setTimeout(()=>{
                context.commit('updateName','wangwu');
            },1000)
        },
        // 对象类解构的写法
        aUpdateName2({state,commit}){
            console.log(state)
            setTimeout(()=>{
                commit('updateName','wangwu');
            },1000)
        }
    },
    getters: {
        fullname(state){
            return state.name + '1111';
        },
        fullname2(state,getters){
            return getters.fullname + '2222';
        },
        // 获取store对象中的state中的数据传入第三个参数
        fullname3(state,getters,rootState){
            return getters.fullname2 + '2222' + rootState.counter;
        }
    }
}